package com.yyfax.pay.third.facade.baofu;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;

import com.yyfax.pay.order.model.to.payin.PayinBatchOrderYYContent;
import com.yyfax.pay.order.model.to.payin.PayinBatchVo;
import com.yyfax.pay.order.model.to.payin.PayinOrderYYContent;
import com.yyfax.pay.order.model.to.payin.PayinSnapshotVo;
import com.yyfax.pay.order.model.to.payin.QueryBatchPayinOrderYYContent;
import com.yyfax.pay.third.model.to.baofu.PayinBatchOrderBaoFuContent;
import com.yyfax.pay.third.model.to.baofu.PayinBatchOrderBaoFuParams;
import com.yyfax.pay.third.model.to.baofu.PayinOrderBaoFuContent;
import com.yyfax.pay.third.model.to.baofu.PayinOrderBaoFuParams;
import com.yyfax.pay.third.model.to.baofu.QueryPayinBatchOrderBaoFuContent;
import com.yyfax.pay.third.model.to.baofu.QueryPayinBatchOrderBaoFuParams;
import com.yyfax.pay.third.model.to.baofu.QueryPayinOrderBaoFuContent;
import com.yyfax.pay.third.model.to.baofu.QueryPayinOrderBaoFuParams;
import com.yyfax.pay.third.model.to.yyfax.payin.QueryPayinOrderYYContent;
import com.yyfax.pay.third.service.ThirdPayService;

public class BaoFuFacade extends ThirdPayService{
	
	@Autowired
	BaoFuTransformService transformService;
	@Autowired
	BaoFuApi baoFuApi;

	@PostConstruct
	private void init() {
		this.facadeName = "宝付";
	}
	
	
	
	/**
	 * 批量代扣
	 * 
	 * @author maojian
	 * @date Apr 27, 2017 8:54:44 AM
	 * @since V1.0.0
	 * @param PayinBatchVo
	 * @return
	 * @throws Exception
	 */
	@Override
	public PayinBatchOrderYYContent payinBatchOrder(PayinBatchVo req) throws Exception{
		PayinBatchOrderBaoFuParams param = transformService.transformPayinBatchOrderParam(req);
		PayinBatchOrderBaoFuContent payinBatchOrderBaoFuContent = baoFuApi.batchPayin(param);
		PayinBatchOrderYYContent content = transformService.transformPayinBatchOrderContent(payinBatchOrderBaoFuContent);
		content.setBatchNo(req.getBatchNo());
		content.setBatchDate(req.getBatchDate());
		content.setAmount(req.getAmount());
		content.setReqUrl(param.getUrl());
		return content;
	}
	
	
	public QueryBatchPayinOrderYYContent queryBatchPayinOrder(PayinBatchVo req) throws Exception{
		QueryPayinBatchOrderBaoFuParams param = transformService.transformQueryPayinBatchOrderParam(req);
		QueryPayinBatchOrderBaoFuContent payinBatchOrderBaoFuContent = baoFuApi.queryBatchPayin(param);
		QueryBatchPayinOrderYYContent content = transformService.transformQueryPayinBatchOrderContent(payinBatchOrderBaoFuContent);
		content.setReqUrl(param.getUrl());
		return content;
	}
	
	public PayinOrderYYContent payinOrder(PayinSnapshotVo req) throws Exception{
		PayinOrderBaoFuParams param = transformService.transformPayinOrderParam(req);
		PayinOrderBaoFuContent payinOrderBaoFuContent = baoFuApi.payin(param);
		PayinOrderYYContent content = transformService.transformPayinOrderContent(payinOrderBaoFuContent);
		content.setAmount(req.getAmount());
		content.setReqUrl(param.getUrl());
		return content;
	}
	
	public QueryPayinOrderYYContent queryPayinOrder(PayinSnapshotVo req)throws Exception{
		QueryPayinOrderBaoFuParams params = transformService.transformQueryPayinOrderParams(req);
		QueryPayinOrderBaoFuContent content = baoFuApi.queryPayinOrder(params);
		QueryPayinOrderYYContent transformContent = transformService.transformQueryPayinOrderContent(content);
		transformContent.setReqUrl(params.getUrl());
		return transformContent;
	}
	
}
